<?php
class Like extends Controller {
	
function Like()
	{
		parent::Controller();	
		$this->load->library('tank_auth');
		$this->lang->load('tank_auth');
		
	}

function index()
	{
		$this->load->view('layout/header');
		$this->load->view('layout/footer');
	}
function do_like($piece_id)
	{
		if (!$this->tank_auth->is_logged_in()) {
				redirect('/auth/login/');
		}
		else{
				$user_id=$this->tank_auth->get_user_id();						
				$data = array( 
					'user_id'	=> $user_id,
					'piece_id'	=> $piece_id,
				);
				$this->db->insert('favoritepieces', $data);
				redirect('piece_view',$piece_id);
		}

	}
}
?>